package cn.iocoder.yudao.module.system.controller.admin.mini.other.turnInfo.controller.admin.turninfo;

import cn.iocoder.yudao.module.system.controller.admin.mini.other.turnInfo.controller.admin.turninfo.vo.TurnInfoPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mini.other.turnInfo.dal.dataobject.turninfo.TurnInfoDO;
import cn.iocoder.yudao.module.system.controller.admin.mini.other.turnInfo.service.turninfo.TurnInfoService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;

import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;


@Tag(name = "管理后台 - 转盘发送记录")
@RestController
@RequestMapping("/qd/turn-info")
@Validated
public class TurnInfoController {

    @Resource
    private TurnInfoService turnInfoService;


    @PostMapping("/create")
    @Operation(summary = "创建转盘发送记录")
    @PreAuthorize("@ss.hasPermission('qd:turn-info:create')")
    public CommonResult<Integer> createTurnInfo(@Valid @RequestBody TurnInfoDO createReqVO) {
        return success(turnInfoService.createTurnInfo(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新转盘发送记录")
    @PreAuthorize("@ss.hasPermission('qd:turn-info:update')")
    public CommonResult<Boolean> updateTurnInfo(@Valid @RequestBody TurnInfoDO updateReqVO) {
        turnInfoService.updateTurnInfo(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除转盘发送记录")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('qd:turn-info:delete')")
    public CommonResult<Boolean> deleteTurnInfo(@RequestParam("id") Integer id) {
        turnInfoService.deleteTurnInfo(id);
        return success(true);
    }

    @GetMapping("/get")
    @Operation(summary = "获得转盘发送记录")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('qd:turn-info:query')")
    public CommonResult getTurnInfo(@RequestParam("id") Integer id) {
        return success(turnInfoService.getTurnInfo(id));
    }

    @GetMapping("/list")
    @Operation(summary = "获得转盘发送记录列表")
    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
    @PreAuthorize("@ss.hasPermission('qd:turn-info:query')")
    public CommonResult  getTurnInfoList(@RequestParam("ids") Collection<Integer> ids) {
        return success(turnInfoService.getTurnInfoList(ids));
    }

    @GetMapping("/page")
    @Operation(summary = "获得转盘发送记录分页")
    @PreAuthorize("@ss.hasPermission('qd:turn-info:query')")
    public CommonResult  getTurnInfoPage(@Valid TurnInfoPageReqVO pageVO) {
        return success(turnInfoService.getTurnInfoPage(pageVO));
    }
//
//    @GetMapping("/export-excel")
//    @Operation(summary = "导出转盘发送记录 Excel")
//    @PreAuthorize("@ss.hasPermission('qd:turn-info:export')")
//    @OperateLog(type = EXPORT)
//    public void exportTurnInfoExcel(@Valid TurnInfoExportReqVO exportReqVO,
//              HttpServletResponse response) throws IOException {
//        List<TurnInfoDO> list = turnInfoService.getTurnInfoList(exportReqVO);
//        // 导出 Excel
//        List<TurnInfoExcelVO> datas = TurnInfoConvert.INSTANCE.convertList02(list);
//        ExcelUtils.write(response, "转盘发送记录.xls", "数据", TurnInfoExcelVO.class, datas);
//    }

}
